---
layout: example
categories: example/v1.0.0
version: v1.0.0
title: Leaflet OSM
description: Query OSM data and add it as a layer to your map using the Leaflet OSM plugin.
tags:
  - plugins
---
<!-- jQuery is required for this example. -->
<script src='https://code.jquery.com/jquery-1.11.0.min.js'></script>
<script src='{{site.tileApi}}/mapbox.js/plugins/leaflet-osm/v0.1.0/leaflet-osm.js'></script>

<div id='map'></div>
<script>
var map = L.mapbox.map('map')
    .addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));

$.ajax({
    url: "https://www.openstreetmap.org/api/0.6/way/260501602/full",
    dataType: "xml",
    success: function (xml) {
        var layer = new L.OSM.DataLayer(xml).addTo(map);
        map.fitBounds(layer.getBounds());
    }
});
</script>
